#include <bits/stdc++.h>
// 2025/02/18
// tag:
// Author: Forever
using namespace std;

using int64 = int64_t;

string dp1[901], dp2[901];
int m, s;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> m >> s;
    if (s == 0 && m == 1) {
        cout << "0 0" << endl;
        return 0;
    }
    if (s == 0 || m * 9 < s) {
        cout << "-1 -1" << endl;
        return 0;
    }

    for (int i = 1; i <= m; i++) {
        for (int j = s; j >= 1; j--) {
            for (int k = 0; k <= 9; k++) {
                if (j >= k && dp1[j - k].size() == i - 1 && i * 9 >= j && (i - 1) * 9 >= j - k) {
                    if (dp1[j].size() < i)
                        dp1[j] = dp1[j - k] + (char)('0' + k);
                    else
                        dp1[j] = min(dp1[j], dp1[j - k] + (char)('0' + k));
                }
                if (j >= k && dp2[j - k].size() == i - 1) {
                    dp2[j] = max(dp2[j], dp2[j - k] + (char)('0' + k));
                }
            }
        }
    }
    cout << dp1[s] << " " << dp2[s] << endl;
    return 0;
}